package com.ruoyi.tranShort.serialPort;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.serialPort.api.callBack.SerialPortCallBack;
import com.ruoyi.tranShort.mqtt.api.WristletWriteBackCallBack;
import com.ruoyi.tranShort.serialPort.common.constants.ControllerNumberConstants;

/**
 * @author wwy
 * @date 2021-08-15 14:44
 */
public class MySerialPortCallBack implements SerialPortCallBack {
    /**
     * 叫哨回复回调函数
     */
    public static WristletWriteBackCallBack wristletWriteBackCallBack;
    @Override
    public void invoke(String data) {
        if(StringUtils.isEmpty(data)){
            return;
        }
        String controllerNum = data.substring(0, 6);
        String deviceCode = data.substring(6, 8);
        switch (controllerNum){
            case ControllerNumberConstants.REPLY_WRISTLET:
                //叫哨回复
                wristletWriteBackCallBack.invoke(deviceCode);
                break;
            default:
                break;
        }
    }
}
